<template>
    <div>
        <el-table
            ref="currencyTable"
            :data="tableData"
            stripe
            style="width: 100%"
            @selection-change="getSelectVal"
        >
            <el-table-column
                type="selection"
                width="55"
                align="center"
            ></el-table-column>
            <el-table-column prop="bizCode" label="编码"></el-table-column>
            <el-table-column prop="purposeDesc" label="描述"></el-table-column>
            <el-table-column prop="title" label="名称"></el-table-column>
            <el-table-column prop="bizTyep" label="业务类型">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.bizTyep == 1">销售业务</el-tag>
                    <el-tag v-else-if="scope.row.bizTyep == 2">采购业务</el-tag>
                    <el-tag v-else-if="scope.row.bizTyep == 3">其他业务</el-tag>
                    <el-tag v-else-if="scope.row.bizTyep == 4">工资发放</el-tag>
                    <span v-else>--</span>
                </template>
            </el-table-column>
            <el-table-column prop="receiptPayType" label="收付款类型">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.receiptPayType == 0">收款</el-tag>
                    <el-tag v-else-if="scope.row.receiptPayType == 1"
                        >付款</el-tag
                    >
                    <span v-else>--</span>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getPayPurposeRemote } from "@/api/finance/receipt";
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1, //当前页
            pageSize: 10, //每页条数
            total: 0,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.pageSize = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.getDataList();
        },
        getSelectVal(val) {
            this.$emit("getSelectVal", val);
        },
        getDataList() {
            getPayPurposeRemote({
                limit: this.pageSize,
                page: this.currentPage,
                receiptPayType: "1",
            }).then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
